package kevin.bigdata.spark.test

import java.io.ObjectInputStream
import java.net.{ServerSocket, Socket}

/**
 * @author: kevin  
 * @date: 21:15 2021/4/29
 */
object Executor {
  def main(args: Array[String]): Unit = {
    // 启动服务器，接受数据
    val server = new ServerSocket(9999)
    println("服务器启动，等待接受数据")

    //等待客户端的连接
    val client: Socket = server.accept

    val in = client.getInputStream

    val objIn = new ObjectInputStream(in)
    val task: SubTask = objIn.readObject().asInstanceOf[SubTask]

    val ints: List[Int] = task.compute()

    println("计算节点[9999]计算表的结果为： ：" + ints)
    objIn.close()
    in.close()
    client.close()
    server.close()
  }
}
